/****************************************************
 * 
 * home soft 版权所有.
 * 
 *****************************************************/

package com.homesoft.runtime.serialization;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author lihg
 * @data 2012-9-13
 */
public class SerializationHelper {
	public final static String HASH_FIELD = "__hash";
	public final static String TYPE_FIELD = "__type";
	public final static String REFERENCE_FIELD = "__reference";
	public final static String CHANGE_SUMMARY_FLAGS = "__changeSummary";
	public final static String dateFormat = "yyyy-MM-ddTHH:mm:ss";

	public static Date ConvertStringToDateTime(String time) throws ParseException {
		SimpleDateFormat format = new SimpleDateFormat(dateFormat);
		return format.parse(time);
	}

	public static String ConvertDateTimeToString(Date dateTime) {
		SimpleDateFormat format = new SimpleDateFormat(dateFormat);
		return format.format(dateTime);
	}
	public static boolean isCollection(Class type)
    {
        boolean isCollection = false;
        //TODO:
        /*if (type.isArray())
        {
            Class t = null;
            Class genericTemplateType = typeof(ICollection);
            Class genericTypeParameter = type.GetGenericArguments()[0];
            t = genericTemplateType.MakeGenericType(genericTypeParameter);

            if (t.IsAssignableFrom(type))
            {
                isCollection = true;
            }
        }
        else
        {
            if (typeof(ICollection).IsAssignableFrom(type))
            {
                isCollection = true;
            }
        }*/
        return isCollection;
    }
}
